import Vue from "vue";
import Vuex from "vuex";
import permission from "./modules/permission";
import user from "./modules/user";
import tagsView from "./modules/tagsView";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    pageSize: 0,
    pageNum: 1,
  },
  mutations: {
    SET_PAGE_NUM(state, num = 1) {
      state.pageNum = num;
    },
    SET_PAGE_SIZE(state, size = 1) {
      state.pageSize = size;
    },
  },
  modules: {
    permission,
    user,
    tagsView,
  },
  // 定义全局getters 方便访问user 模块的roles
  getters: {
    roles: (state) => state.user.roles,
    permission_routes: (state) => state.permission.routes,
  },
});
